import Vue from 'vue';
import Router from 'vue-router';
const _import = require('./_import_' + process.env.NODE_ENV);
// in development env not use Lazy Loading,because Lazy Loading large page will cause webpack hot update too slow.so only in production use Lazy Loading

/* empty-route */
import Empty from '../views/layout/Empty';

/* index */
const Index = _import('index');

/* header导航 */
const Vip = _import('header-links/vip')
const Recharge = _import('header-links/recharge')
const Withdraw = _import('header-links/withdraw')
const Upload = _import('header-links/upload')// 资源上传
const Concat = _import('header-links/concat')

/* ressource */
/*
* 资源页面样式分类：
* 累积，归类复习，教子有方，作文
* 课件，作文课件，教案，试卷，修辞，论文
* 听阅
*/
const Courseware = _import('courseware/index')// 课件（阅读课件）
const CComposition = _import('courseware/composition')// 作文课件
const Resource = _import('resources/resource')// 通用资源组件：教案、试卷、论文
const TeachChild = _import('resources/teach-child')// 教子有方
const Listen = _import('resources/listen')// 听阅
const Composition = _import('resources/composition')// 作文
const Trope = _import('resources/trope')// 修辞
const Accumulation = _import('resources/accumulation')// 积累
const WechatLib = _import('resources/wechat-lib')// 微库
const ClassifyReview = _import('resources/classify-review')// 归类复习
const Paper = _import('resources/paper')// 试卷

const Search = _import('resources/search')// 搜索页面

const ResourcePreview = _import('resources/resource-preview')
const ResourceDownload = _import('resources/resource-download')
/* 练习 */
const Practise = _import('practise/index')
const uploadPractise1 = _import('practise/uploadPractise1')
const uploadPractise2 = _import('practise/uploadPractise2')
const Pdetail = _import('practise/practise-detail')

/* 同城优教 */
const School = _import('school/index')
const OrgInfo = _import('school/info')

/* 社群 */
const Community = _import('community/index')
/* teacher */
const TeacherList = _import('teacher/teacher-list')// 名师入驻
const TeacherInfo = _import('teacher/teacher-info')// 教师详情
const FamousTeacher = _import('teacher/famous-teacher')// 名师讲堂
const TeacherCourse = _import('teacher/teacher-course')// 名师讲堂

/* customized */
const Customized = _import('customized/index')// 私人定制
const CustomizedDetail = _import('customized/detail')// 私人定制
const CustomizedMy = _import('customized/my')// 私人定制
const MyCustomized = _import('customized/myCustomizedList')// 私人定制

/* mall */
/* 语典书城 */
const Mall = _import('mall/index')
const MallList = _import('mall/list')
const Dream = _import('mall/dream')
const MyDream = _import('mall/myDream')
const Trade = _import('mall/trade')
const Commodity = _import('mall/commodity')
const DreamDetail = _import('mall/dreamDetail')
const MallCart = _import('mall/shopcar')
const OrderList = _import('mall/orderList')
const MallOrder = _import('mall/order') // 付款界面

/* 语典好物 */
const Good = _import('mall/good')
const GoodList = _import('mall/goodList')
const Thing = _import('mall/thing')
/* tools */
const Tools = _import('tools/index')
/* personal center */
import Personal from '../views/layout/Personal'
const Info = _import('personal/info')
const InfoIndex = _import('personal/info/index')
const InfoEdit = _import('personal/info/edit')

const Money = _import('personal/money')
const MoneyIndex = _import('personal/money/index')
const MoneyMore = _import('personal/money/more')
const Shopcar = _import('personal/shopcar')
const Order = _import('personal/order')
const OrderCourse = _import('personal/order-course')
const MyUpload = _import('personal/upload')
const Download = _import('personal/download')
const History = _import('personal/history')
const Collection = _import('personal/collection')
const Play = _import('personal/play')

const Security = _import('personal/security')
const SecurityIndex = _import('personal/security/index')
const CheckBefore = _import('personal/security/check-before')
const ChangePwd = _import('personal/security/change-pwd')
const SetNew = _import('personal/security/set-new')

const Time = _import('personal/time')

const MyTeacherInfo = _import('personal/teacher-info')
const BaseInfo = _import('personal/teacher-info/index')
const BaseInfoEdit = _import('personal/teacher-info/edit')
const Individuation = _import('personal/teacher-info/individuation')
const Course = _import('personal/teacher-info/course')

const SchoolInfo = _import('personal/school-info')
const HasSite = _import('personal/school-info/has-site')
const NoSite = _import('personal/school-info/no-site')

/* error page */
const Err404 = _import('error/404');
// const Err401 = _import('error/401');

Vue.use(Router);

 /**
  * icon : the icon show in the sidebar
  * hidden : if hidden:true will not show in the sidebar
  * redirect : if redirect:noredirect will not redirct in the levelbar
  * noDropdown : if noDropdown:true will not has submenu
  * meta : { role: ['admin'] }  will control the page role
  **/

export const constantRouterMap = [
  {
    path: '/',
    redirect: '/home',
    component: Empty,
    name: '首页',
    children: [{ path: 'home', component: Index }]
  }, {
    path: '/vip',
    name: '开通vip',
    component: Vip
  }, {
    path: '/recharge',
    name: '在线充值',
    component: Recharge
  }, {
    path: '/withdraw',
    name: '提现',
    component: Withdraw
  }, {
    path: '/concat',
    name: '联系我们',
    component: Concat
  }, {
    path: '/listen',
    name: '听阅',
    component: Listen
  }, {
    path: '/composition',
    name: '作文',
    component: Composition
  }, {
    path: '/resource/preview/:id',
    name: '资源预览',
    component: ResourcePreview
  }, {
    path: '/resource/download/:id',
    name: '资源下载',
    component: ResourceDownload
  }, {
    path: '/search',
    name: '搜索',
    component: Search
  }, {
    path: '/courseware',
    name: '课件',
    component: Courseware
  }, {
    path: '/ccomposition',
    name: '作文课件',
    component: CComposition
  }, {
    path: '/practise',
    name: '练习',
    component: Practise
  }, {
    path: '/practise-detail',
    name: '练习详情',
    component: Pdetail
  }, {
    path: '/upload-practise1',
    name: '发布练习1',
    component: uploadPractise1
  }, {
    path: '/upload-practise2',
    name: '发布练习2',
    component: uploadPractise2
  }, {
    path: '/trope',
    name: '修辞',
    component: Trope
  }, {
    path: '/accumulation',
    name: '累积',
    component: Accumulation
  }, {
    path: '/wechat-lib',
    name: '微库',
    component: WechatLib
  }, {
    path: '/classify-review',
    name: '归类复习',
    component: ClassifyReview
  }, {
    path: '/test-paper',
    name: '试卷',
    component: Paper
  }, {
    path: '/teaching-plan',
    name: '教案',
    component: Resource
  }, {
    path: '/paper',
    name: '论文',
    component: Resource
  }, {
    path: '/teach-child',
    name: '教子有方',
    component: TeachChild
  }, {
    path: '/upload',
    name: '我要上传',
    component: Upload
  }, {
    path: '/community',
    name: '社群',
    component: Community
  }, {
    path: '/school',
    name: '同城优教',
    component: Empty,
    redirect: '/school/list',
    children: [
      { path: 'list', component: School, name: '优教列表' },
      { path: ':id', component: OrgInfo, name: '优教详情' }
    ]
  }, {
    path: '/famous-teacher',
    name: '名师讲堂',
    component: FamousTeacher
  }, {
    path: '/teacher-course/:id',
    name: '名师课程',
    component: TeacherCourse
  }, {
    path: '/teacher',
    name: '名师入驻',
    component: Empty,
    redirect: '/teacher/list',
    children: [
      { path: 'list', component: TeacherList, name: '教师列表' },
      { path: ':id', component: TeacherInfo, name: '教师个人信息' }
    ]
  }, {
    path: '/customized',
    name: '私人定制',
    component: Customized
  }, {
    path: '/my-customized',
    name: '我的私人定制',
    component: MyCustomized
  }, {
    path: '/customized/detail/:id',
    name: '私人定制详情',
    component: CustomizedDetail
  }, {
    path: '/customized/my/:id',
    name: '私人定制详情-我的征稿',
    component: CustomizedMy
  }, {
    path: '/mall',
    name: '语典商城',
    redirect: '/mall/index',
    component: Empty,
    children: [
      { path: 'index', component: Mall, name: '语典书城' },
      { path: 'list', component: MallList, name: '语典书城列表' },
      { path: 'good-list', component: GoodList, name: '语典好物列表' },
      { path: 'good-list/:id', component: Thing, name: '语典好物详情' },
      { path: 'list/:id', component: Commodity, name: '商品详情' },
      { path: 'shopcar', component: MallCart, name: '商城购物车' },
      { path: 'order-list', component: OrderList, name: '商城订单列表' },
      { path: 'shopcar/:ids', component: MallOrder, name: '商城订单' }, // 付款界面
      { path: 'dream', component: Dream, name: '语典圆梦' },
      { path: 'my-dream', component: MyDream, name: '我参与的' },
      { path: 'dream-detail/:id', component: DreamDetail, name: '圆梦详情' },
      { path: 'trade', component: Trade, name: '语点交易' },
      { path: 'good', component: Good, name: '语点好物' }
    ]
  }, {
    path: '/tools',
    name: '语典工具',
    component: Tools
  }, {
    path: '/personal',
    redirect: '/personal/info',
    component: Personal,
    name: '个人中心',
    children: [
      {
        path: 'info',
        component: Info,
        redirect: 'info/index',
        name: '个人信息',
        children: [
          { path: 'index', component: InfoIndex, name: '个人信息 ' },
          { path: 'edit', component: InfoEdit, name: '个人信息  ' }
        ]
      },
      {
        path: 'money',
        component: Money,
        redirect: 'money/index',
        name: '我的钱包',
        children: [
          { path: 'index', component: MoneyIndex, name: '我的钱包 ' },
          { path: 'more', component: MoneyMore, name: '我的钱包  ' }
        ]
      },
      { path: 'shopcar', component: Shopcar, name: '购物车' },
      { path: 'order', component: Order, name: '我的订单' },
      { path: 'order-course', component: OrderCourse, name: '订购课程' },
      { path: 'upload', component: MyUpload, name: '我的上传' },
      { path: 'download', component: Download, name: '我的下载' },
      { path: 'history', component: History, name: '浏览历史' },
      { path: 'collection', component: Collection, name: '我的收藏' },
      { path: 'play', component: Play, name: '我的播单' },
      {
        path: 'security',
        component: Security,
        redirect: 'security/index',
        name: '安全设置',
        children: [
          { path: 'index', component: SecurityIndex, name: '安全设置 ' },
          { path: 'check-before', component: CheckBefore, name: '安全设置  ' },
          { path: 'set-new', component: SetNew, name: '安全设置   ' },
          { path: 'change-pwd', component: ChangePwd, name: '安全设置    ' }
        ]
      },
      { path: 'time', component: Time, name: '上课时间' },
      {
        path: 'teacher-info',
        component: MyTeacherInfo,
        redirect: 'teacher-info/base-info',
        name: '教师信息',
        children: [
          {
            path: 'base-info',
            component: Empty,
            redirect: 'base-info/index',
            name: '教师信息 ',
            children: [
              { path: 'index', component: BaseInfo, name: '教师信息  ' },
              { path: 'edit', component: BaseInfoEdit, name: '教师信息   ' }
            ]
          },
          { path: 'individuation', component: Individuation, name: '教师信息    ' },
          { path: 'course', component: Course, name: '教师信息     ' }
        ]
      },
      {
        path: 'school-info',
        component: SchoolInfo,
        redirect: 'school-info/no-site',
        name: '优教机构信息',
        children: [
          { path: 'has-site', component: HasSite, name: '优教机构信息 ' },
          { path: 'no-site', component: NoSite, name: '优教机构信息  ' }
        ]
      }
    ]
  },
  { path: '/404', component: Err404, name: '404' },
  { path: '*', redirect: '/404' }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
});

export const asyncRouterMap = [];
